﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Cors;

namespace LdCms.Web.Controllers.API.Map.V1
{
    using LdCms.Common.Extension;
    using LdCms.Common.Net;
    using LdCms.EF.DbModels;
    using LdCms.IBLL.Map;
    using LdCms.Plugins.Map.Amap.Models;
    using LdCms.Plugins.Map.Amap;
    using LdCms.Web.Services;
    /// <summary>
    /// 高德地图 WebService API 注：入口参数为官方参数参数
    ///   1.1、地理编码
    ///        URL：map/amap/ws/geocode/geo?uuid=uuid     
    ///        POST：{"address":""}
    ///   1.2、逆地理编码
    ///        URL：map/amap/ws/geocode/regeo?uuid=uuid     
    ///        POST：{"location":""}
    ///   2.1、路径规划 - 步行路径规划
    ///        URL：map/amap/ws/direction/walking?uuid=uuid     
    ///        POST：{"origin":"116.434307,39.90909","destination":"116.434446,39.90816"}
    ///   2.2、路径规划 - 公交路径规划
    ///        URL：map/amap/ws/direction/transit?uuid=uuid     
    ///        POST：{"origin":"116.434307,39.90909","destination":"116.434446,39.90816","city":"01"}
    ///   2.3、路径规划 - 驾车路径规划
    ///        URL：map/amap/ws/direction/driving?uuid=uuid     
    ///        POST：{"origin":"116.434307,39.90909","destination":"116.434446,39.90816","extensions":"all"}
    ///   2.4、路径规划 - 骑行路径规划
    ///        URL：map/amap/ws/direction/bicycling?uuid=uuid     
    ///        POST：{"origin":"116.434307,39.90909","destination":"116.434446,39.90816"}
    ///   2.5、路径规划 - 货车路径规划
    ///        URL：map/amap/ws/direction/truck?uuid=uuid     
    ///        POST：{"origin":"116.434307,39.90909","destination":"116.434446,39.90816","size":"3"}
    ///   2.6、路径规划 - 距离测量
    ///        URL：map/amap/ws/distance?uuid=uuid     
    ///        POST：{"origins":"116.434307,39.90909","destination":"116.434446,39.90816"}
    ///   3.1、行政区域查询 
    ///        URL：map/amap/ws/district?uuid=uuid     
    ///        POST：{"keywords":"","subdistrict":""}
    ///   4.1、搜索POI - 关键字搜索
    ///        URL：map/amap/ws/place/text?uuid=uuid     
    ///        POST：{"keywords":"","types":""}
    ///   4.2、搜索POI - 周边搜索
    ///        URL：map/amap/ws/place/around?uuid=uuid     
    ///        POST：{"location":""}
    ///   4.3、搜索POI - 多边形搜索
    ///        URL：map/amap/ws/place/polygon?uuid=uuid     
    ///        POST：{"polygon":""}
    ///   4.4、搜索POI - ID查询
    ///        URL：map/amap/ws/place/detail?uuid=uuid     
    ///        POST：{"id":""}
    ///   5.1、IP定位
    ///        URL：map/amap/ws/ip?uuid=uuid     
    ///        POST：{"ip":""}
    ///   6.1、静态地图
    ///        URL：map/amap/ws/staticmap?uuid=uuid     
    ///        POST：{"location":"","zoom":"14"}
    ///   7.1、坐标转换
    ///        URL：map/amap/ws/assistant/coordinate/convert?uuid=uuid     
    ///        POST：{"locations":""}
    ///   8.1、天气查询
    ///        URL：map/amap/ws/weather/info?uuid=uuid     
    ///        POST：{"city":""}
    ///   9.1、输入提示
    ///        URL：map/amap/ws/assistant/inputtips?uuid=uuid     
    ///        POST：{"keywords":""}
    ///  10.1、交通态势 - 矩形区域交通态势
    ///        URL：map/amap/ws/traffic/status/rectangle?uuid=uuid     
    ///        POST：{"rectangle":""}
    ///  10.2、交通态势 - 圆形区域交通态势
    ///        URL：map/amap/ws/traffic/status/circle?uuid=uuid     
    ///        POST：{"location":""}
    ///  10.3、交通态势 - 指定线路交通态势
    ///        URL：map/amap/ws/traffic/status/road?uuid=uuid     
    ///        POST：{"name":"","city":"","adcode":""}
    /// </summary>
    [ApiVersion("1.0")]
    [ControllerName("map/amap/ws")]
    public class MapAmapWebServiceController : BaseApiController
    {
        private readonly IBaseApiManager BaseApiManager;
        private readonly IAmapPlatformService AmapPlatformService;
        public MapAmapWebServiceController(IBaseApiManager BaseApiManager, IAmapPlatformService AmapPlatformService) : base(BaseApiManager)
        {
            this.BaseApiManager = BaseApiManager;
            this.AmapPlatformService = AmapPlatformService;
        }
        private Ld_Map_AmapPlatform MapAmapPlatform
        {
            get
            {
                var entity = AmapPlatformService.GetAmapPlatformByDefault(InterfaceAccount.SystemID, InterfaceAccount.CompanyID);
                if (entity == null)
                    throw new Exception("get amap helper config fail！");
                return entity;
            }
        }
        private AmapMapHelper AmapMapHelper
        {
            get
            {
                return new AmapMapHelper(MapAmapPlatform.Key, MapAmapPlatform.PrivateKey);
            }
        }
        
        #region 地理/逆地理编码
        [HttpPost]
        [ActionName("geocode/geo")]
        public IActionResult GeocodeGeo(string uuid, [FromBody]GeocodeGeo fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsGeocodeGeoParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetGeocodeGeo(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        [HttpPost]
        [ActionName("geocode/regeo")]
        public IActionResult GeocodeRegeo(string uuid, [FromBody]GeocodeRegeo fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsGeocodeRegeoParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetGeocodeRegeo(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 路径规划 
        [HttpPost]
        [ActionName("direction/walking")]
        public IActionResult DirectionWalking(string uuid, [FromBody]DirectionWalking fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsDirectionWalkingParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetDirectionWalking(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        [HttpPost]
        [ActionName("direction/transit")]
        public IActionResult DirectionTransit(string uuid, [FromBody]DirectionTransit fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsDirectionTransitParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetDirectionTransit(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        [HttpPost]
        [ActionName("direction/driving")]
        public IActionResult DirectionDriving(string uuid, [FromBody]DirectionDriving fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsDirectionDrivingParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetDirectionDriving(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        [HttpPost]
        [ActionName("direction/bicycling")]
        public IActionResult DirectionBicycling(string uuid, [FromBody]DirectionBicycling fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsDirectionBicyclingParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetDirectionBicycling(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        [HttpPost]
        [ActionName("direction/truck")]
        public IActionResult DirectionTruck(string uuid, [FromBody]DirectionTruck fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsDirectionTruckParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetDirectionTruck(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        [HttpPost]
        [ActionName("distance")]
        public IActionResult Distance(string uuid, [FromBody]Distance fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsDistanceParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetDistance(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 行政区域查询 
        [HttpPost]
        [ActionName("district")]
        public IActionResult District(string uuid, [FromBody]District fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsDistrictParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetDistrict(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 搜索POI 
        [HttpPost]
        [ActionName("place/text")]
        public IActionResult PlaceText(string uuid, [FromBody]PlaceText fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsPlaceTextParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetPlaceText(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }

        [HttpPost]
        [ActionName("place/around")]
        public IActionResult PlaceAround(string uuid, [FromBody]PlaceAround fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsPlaceAroundParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetPlaceAround(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }

        [HttpPost]
        [ActionName("place/polygon")]
        public IActionResult PlacePolygon(string uuid, [FromBody]PlacePolygon fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsPlacePolygonParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetPlacePolygon(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }

        [HttpPost]
        [ActionName("Place/detail")]
        public IActionResult PlaceDetail(string uuid, [FromBody]PlaceDetail fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsPlaceDetailParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetPlaceDetail(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region IP定位 
        [HttpPost]
        [ActionName("ip")]
        public IActionResult IP(string uuid, [FromBody]IP fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsIPParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetIP(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 静态地图 
        [HttpPost]
        [ActionName("staticmap")]
        public IActionResult Staticmap(string uuid, [FromBody]Staticmap fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsStaticmapParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetStaticmap(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 坐标转换 
        [HttpPost]
        [ActionName("assistant/coordinate/convert")]
        public IActionResult AssistantCoordinateConvert(string uuid, [FromBody]AssistantCoordinateConvert fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsAssistantCoordinateConvertParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetAssistantCoordinateConvert(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 天气查询 
        [HttpPost]
        [ActionName("weather/info")]
        public IActionResult WeatherInfo(string uuid, [FromBody]WeatherInfo fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsWeatherInfoParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetWeatherInfo(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 输入提示
        [HttpPost]
        [ActionName("assistant/inputtips")]
        public IActionResult AssistantInputtips(string uuid, [FromBody]AssistantInputtips fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsAssistantInputtipsParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetAssistantInputtips(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 交通态势
        [HttpPost]
        [ActionName("traffic/status/rectangle")]
        public IActionResult TrafficStatusRectangle(string uuid, [FromBody]TrafficStatusRectangle fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsTrafficStatusRectangleParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetTrafficStatusRectangle(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        [HttpPost]
        [ActionName("traffic/status/circle")]
        public IActionResult TrafficStatusCircle(string uuid, [FromBody]TrafficStatusCircle fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsTrafficStatusCircleParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetTrafficStatusCircle(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        [HttpPost]
        [ActionName("traffic/status/road")]
        public IActionResult TrafficStatusRoad(string uuid, [FromBody]TrafficStatusRoad fromValue)
        {
            long logId = 0;
            try
            {
                logId = BaseApiManager.SaveLogs(uuid, fromValue);
                bool sisParams = IsTrafficStatusRoadParams(fromValue);
                fromValue.key = AmapMapHelper.Key;
                var result = AmapMapHelper.GetTrafficStatusRoad(fromValue);
                return Result(logId, result);
            }
            catch (Exception ex)
            {
                return Error(logId, ex.Message);
            }
        }
        #endregion

        #region 私有化验证
        private bool IsGeocodeGeoParams(GeocodeGeo fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.address))
                    throw new Exception("lack address params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsGeocodeRegeoParams(GeocodeRegeo fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.location))
                    throw new Exception("lack location params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsDirectionWalkingParams(DirectionWalking fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.origin))
                    throw new Exception("lack origin params！");
                if (string.IsNullOrEmpty(fromValue.destination))
                    throw new Exception("lack destination params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsDirectionTransitParams(DirectionTransit fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.origin))
                    throw new Exception("lack origin params！");
                if (string.IsNullOrEmpty(fromValue.destination))
                    throw new Exception("lack destination params！");
                if (string.IsNullOrEmpty(fromValue.city))
                    throw new Exception("lack city params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsDirectionDrivingParams(DirectionDriving fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.origin))
                    throw new Exception("lack origin params！");
                if (string.IsNullOrEmpty(fromValue.destination))
                    throw new Exception("lack destination params！");
                if (string.IsNullOrEmpty(fromValue.extensions))
                    throw new Exception("lack extensions params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsDirectionBicyclingParams(DirectionBicycling fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.origin))
                    throw new Exception("lack origin params！");
                if (string.IsNullOrEmpty(fromValue.destination))
                    throw new Exception("lack destination params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsDirectionTruckParams(DirectionTruck fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.origin))
                    throw new Exception("lack origin params！");
                if (string.IsNullOrEmpty(fromValue.destination))
                    throw new Exception("lack destination params！");
                if (string.IsNullOrEmpty(fromValue.size))
                    throw new Exception("lack size  params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsDistanceParams(Distance fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.origins))
                    throw new Exception("lack origins params！");
                if (string.IsNullOrEmpty(fromValue.destination))
                    throw new Exception("lack destination params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsDistrictParams(District fromValue)
        {
            try
            {
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsPlaceTextParams(PlaceText fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.keywords))
                    throw new Exception("lack keywords params！");
                if (string.IsNullOrEmpty(fromValue.types))
                    throw new Exception("lack types params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsPlaceAroundParams(PlaceAround fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.location))
                    throw new Exception("lack location params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsPlacePolygonParams(PlacePolygon fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.polygon))
                    throw new Exception("lack polygon params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsPlaceDetailParams(PlaceDetail fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.id))
                    throw new Exception("lack id params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsIPParams(IP fromValue)
        {
            try
            {
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsStaticmapParams(Staticmap fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.location))
                    throw new Exception("lack location params！");
                if (string.IsNullOrEmpty(fromValue.zoom))
                    throw new Exception("lack zoom params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsAssistantCoordinateConvertParams(AssistantCoordinateConvert fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.locations))
                    throw new Exception("lack locations params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsWeatherInfoParams(WeatherInfo fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.city))
                    throw new Exception("lack city params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsAssistantInputtipsParams(AssistantInputtips fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.keywords))
                    throw new Exception("lack keywords params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsTrafficStatusRectangleParams(TrafficStatusRectangle fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.rectangle))
                    throw new Exception("lack rectangle params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsTrafficStatusCircleParams(TrafficStatusCircle fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.location))
                    throw new Exception("lack location params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private bool IsTrafficStatusRoadParams(TrafficStatusRoad fromValue)
        {
            try
            {
                if (fromValue == null)
                    throw new Exception("params not empty！");
                if (string.IsNullOrEmpty(fromValue.name))
                    throw new Exception("lack keywords params！");
                if (string.IsNullOrEmpty(fromValue.city))
                    throw new Exception("lack city params！");
                if (string.IsNullOrEmpty(fromValue.adcode))
                    throw new Exception("lack adcode params！");
                return true;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        #endregion

    }
}